import { ref } from "vue";
import './../../../src/style.less'
import Mock from 'mockjs'

export default function (rowLength: number = 3){
    const columns = ref([
        // { 
        //     title: '行号', 
        //     width: 34, 
        //     rander: ({ rowIndex }) =>  rowIndex < 0 ? columns.value[0].title : rowIndex + 1,
        //     readonly: true
        // },
        {
            title: 'Name(只读)',
            dataIndex: 'name',
            key: 'name',
            readonly: true
        },
        {
            title: 'Gender（下拉选择）',
            dataIndex: 'sex',
            key: 'sex',
            type: 'select',
            options: [{ label: "男", value: '0'}, { label: "女", value: '1' } ],
        },
        {
            title: 'Age（数字）',
            dataIndex: 'age',
            key: 'age',
            type: 'number',
        },
        {
            title: 'Address',
            dataIndex: 'address',
            key: 'address',
        },
        {
            title: '出生日期',
            dataIndex: 'date',
            key: 'date',
            type: 'date',
            width: 120,
        },
        {
            title: '兴趣爱好',
            dataIndex: 'igree',
            key: 'igree',
            type: 'checkbox',
            options: [{ label: "篮球", value: '0'}, { label: "足球", value: '1' } ],
            width: 120,
        },
        {
            title: '意向',
            dataIndex: 'tt',
            key: 'tt',
            type: 'radio',
            options: [{ label: "篮球", value: '0'}, { label: "足球", value: '1' } ],
            width: 120,
        },
    ])

    const templeteKey = `data|${rowLength}`
    const data = Mock.mock({
        [templeteKey]: [{ 
                'id|+1': 1,
                'name': '@cname()',
                'sex|1': ['1', '0'],
                'age|20-50': 20,
                'address': '@county(true)',
                'date': '@date()',
                'igree|1': [['0'], ['1'], ['0', '1']],
                'tt|1': ['0', '1'],
        }]
    })
    const dataSource = ref(data.data)

    return { columns, dataSource }
}